X!! allocates the colors itself now.
const GdkColor *color)
{
GdkWindowObject *private = (GdkWindowObject *)window;
- GdkColormap *colormap = gdk_drawable_get_colormap (window);
private->bg_color = *color;
- gdk_colormap_query_color (colormap, private->bg_color.pixel, &private->bg_color);
if (private->bg_pixmap &&
private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
* you're an application - or gtk_style_set_background() - if you're
* implementing a custom widget.)
*
- * The @color must be allocated; gdk_rgb_find_color() is the best way
- * to allocate a color.
- *
* See also gdk_window_set_background_pixmap().
*/
void
const GdkColor *color)
{
GdkWindowObject *private;
- GdkColormap *colormap = gdk_drawable_get_colormap (window);
GdkWindowImplIface *impl_iface;
g_return_if_fail (GDK_IS_WINDOW (window));
private = (GdkWindowObject *) window;
private->bg_color = *color;
- gdk_colormap_query_color (colormap, private->bg_color.pixel, &private->bg_color);
if (private->bg_pixmap &&
private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
gdk_window_x11_set_background (GdkWindow *window,
const GdkColor *color)
{
+ GdkColor allocated = *color;
+
+ if (!gdk_colormap_alloc_color (gdk_drawable_get_colormap (window),
+ &allocated,
+ TRUE, TRUE))
+ return;
+
XSetWindowBackground (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window), color->pixel);
+ GDK_WINDOW_XID (window), allocated.pixel);
+
+ gdk_colormap_free_colors (gdk_drawable_get_colormap (window), &allocated, 1);
}
static void